<?php
	function getPage($fvsWebUrl)
	{

		$ch = curl_init();
		curl_setopt($ch, CURLOPT_URL,$fvsWebUrl);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
		curl_setopt($ch, CURLOPT_TIMEOUT, 60);
		$ret = curl_exec ($ch);
		curl_close($ch);

		return $ret;
	}
?><h1>Robot</h1>
<div>Use this form to (nearly) automate your tweets!</div>
<h3>1. Choose a trend:</h3>
<select id="selTrends">
<?php
	$jsonPage = getPage("http://search.twitter.com/trends/current.json");
	$jsonDecode = json_decode($jsonPage);
	$variables = get_object_vars($jsonDecode->trends);
	$keys = array_keys($variables);

	foreach ($jsonDecode->trends->$keys[0] as $trend)
	{
?>
		<option name="<?php echo $trend->query; ?>" value="<?php echo $trend->query; ?>"><?php echo $trend->name; ?></option>
<?php
	}
?>
</select>
<br />
<h3>2. Choose an emotion:</h3>
<select id="selEmotions">
<?php
	$emotions = array(
		'Happy',
		'Sad',
		'Angry',
		'Blah',
		'Elated',
		'Depressed',
		'Smug',
		'Envious',
	);

	foreach ($emotions as $emotion)
	{
?>
		<option name="<?php echo $emotion ?>" value="<?php echo $emotion; ?>"><?php echo $emotion; ?></option>
<?php
	}
?>
</select>
<br />
<h3>3. Choose a phrase:</h3>
<select id="selPhrases">
<?php
	//include the corresponding emotion file

	
	$emotions = array(
		'Happy',
		'Sad',
		'Angry',
		'Blah',
		'Elated',
		'Depressed',
		'Smug',
		'Envious',
	);

	foreach ($emotions as $emotion)
	{
?>
		<option name="<?php echo $emotion ?>" value="<?php echo $emotion; ?>"><?php echo $emotion; ?></option>
<?php
	}
?>
</select>